package online.longzipeng.mywebdemo.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import online.longzipeng.mywebdemo.commen.Result;
import online.longzipeng.mywebdemo.commen.exception.ErrorCodeEnum;
import online.longzipeng.mywebdemo.commen.exception.ServiceException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: lzp
 * @description:
 * @Date: 2023/10/30
 */
@RestController
@RequestMapping("/test")
@Api(tags = "测试接口")
public class TestController {

	@GetMapping("/error")
	@ApiOperation("测试异常抛出")
	public Result<String> testError(@RequestParam @ApiParam("1 正常 2抛出错误") Integer type) {
		if (type == 2) {
			throw new ServiceException(ErrorCodeEnum.USER_LOGIN_ERROR);
		}
		return Result.success("你好呀~");
	}

}
